package com.nbsystem.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nbsystem.entity.ElcNotice;
import com.nbsystem.entity.ViewNotice;
import com.nbsystem.service.ElcInfotypeService;
import com.nbsystem.service.ElcNoticeService;
import com.nbsystem.util.MyWorldFilter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

/**
 * (ElcNotice)表控制层
 *
 * @author makejava
 * @since 2021-06-01 15:01:28
 */
@Controller
@RequestMapping("elcNotice")
public class ElcSyncNoticeController {
    /**
     * 服务对象
     */
    @Resource
    private ElcNoticeService elcNoticeService;
    @Resource
    private MyWorldFilter myWorldFilter;


    @RequestMapping("insert")
    public  String insertElcNotice(ElcNotice elcNotice, HttpServletRequest request){
        elcNotice.setIsEnable(0);
        elcNotice.setIsComment(0);
        elcNotice.setClicks(0);
        elcNotice.setIsTop(0);
        elcNotice.setDel(0);
        elcNotice.setDpid(1);
        elcNotice.setContent(myWorldFilter.filterWorld((String) elcNotice.getContent()));
        elcNotice.setCreateTime(new Date());
        elcNotice.setUpdateTime(new Date());
        elcNoticeService.insert(elcNotice);
        return  "redirect:"+request.getServletContext().getContextPath()+"/notice/index";
    }
    @RequestMapping("update")
    public String updateNotice(ElcNotice elcNotice,HttpServletRequest request) {
        elcNotice.setContent(myWorldFilter.filterWorld((String) elcNotice.getContent()));
        elcNotice.setUpdateTime(new Date());
        elcNoticeService.update(elcNotice);
        return "redirect:"+request.getServletContext().getContextPath()+"/notice/index";
    }


}